package FunctionPackage;

import BookListPackage.BookList;

import java.util.Scanner;

public class Borrowing implements Function {
    @Override
    public void work(BookList bookList) {
        System.out.println("借阅图书！");
        System.out.println("请输入要借阅的书名：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();

        //遍历寻找
        for (int i = 0; i < bookList.amount; i++) {
            if (bookName.equals(bookList.books[i].getBookName())) {
                bookList.books[i].setBorrow(true);
                System.out.println("-------找到了，借阅成功！！！-------");
                return;
            }
        }
        System.out.println("--------找不到该书，借阅失败！！！--------");
    }
}
